<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="StyleSheet" type="text/css" href="dashboard.css"  />
<title>Dashboard</title>
<script>

window.onload=hideURLfield;

function toggleURLfield(){

	var value = document.getElementById("displayAnotherPageInstead").value;
	
	if(value == "0")
		hideURLfield();
	if(value == "1")
		showURLfield();
	if(value == "2")
		showURLfield();
}

function hideURLfield() {
	document.getElementById("urlRow").style.display = "none";
}

function showURLfield() {
	document.getElementById("urlRow").style.display = "table-row";
}

function updateXML(){

	var displayAnotherPageInstead = document.getElementById("displayAnotherPageInstead").value;

	
	var pageToDisplayURL = document.getElementById("pageToDisplayURL").value;

	var hideMostVisited = document.getElementById("hideMostVisited").checked;
	var hideSearches = document.getElementById("hideSearches").checked;
	var hideRecentBookmarks = document.getElementById("hideRecentBookmarks").checked;
	var hideRecentlyClosedTabs = document.getElementById("hideRecentlyClosedTabs").checked;
	
	var configXML = "<config>\r\n";
	
	configXML+="<displayAnotherPageInstead>"+ displayAnotherPageInstead +"</displayAnotherPageInstead>\r\n";
	
	if(displayAnotherPageInstead == 1 || displayAnotherPageInstead == 2)
		configXML+="<pageToDisplayURL>"+pageToDisplayURL+"</pageToDisplayURL>\r\n";
	
	configXML+="<hideMostVisited>"+hideMostVisited+"</hideMostVisited>\r\n";
	configXML+="<hideSearches>"+hideSearches+"</hideSearches>\r\n";
	configXML+="<hideRecentBookmarks>"+hideRecentBookmarks+"</hideRecentBookmarks>\r\n";
	configXML+="<hideRecentlyClosedTabs>"+hideRecentlyClosedTabs+"</hideRecentlyClosedTabs>\r\n";
	configXML+="</config>";
	
	document.getElementById("xmlArea").firstChild.data = configXML;
}

</script>
</head>

<body>

<div id="container">

<div id="header"></div>

<div id="content">

<h1>CustomNewTab Dashboard</h1>

<table id="formTable" >
<tr>
	<td class="label">
		<span>Redirect: </span>
	</td>
	<td>
		<select id="displayAnotherPageInstead" onchange="toggleURLfield()">
			<option value="0">Do not display another page</option>
			<option value="1">Redirect to another page</option>
			<option value="2">Embed another page</option>
		</select>
	</td>
</tr>
<tr id="urlRow">
	<td class="label">URL:</td>
	<td><input type="text" value="http://www.google.com/" size="25" id="pageToDisplayURL"/>
</tr>
<tr>

	<td colspan="2"><hr /><td><tr>
	
<tr>
	<td class="label">	
		<label for="hideMostVisited">Hide most visited section: </label>
	</td>
	<td>
		<input type="checkbox" id="hideMostVisited" />
	</td>
</tr>
<tr>
	<td class="label">
		<label for="hideSearches">Hide searches: </label>
	</td>
	<td>
		<input type="checkbox" id="hideSearches" />
	</td>
</tr>
<tr>
	<td class="label">
		<label for="hideRecentBookmarks">Hide recent bookmarks: </label>
	</td>
	<td>
		<input type="checkbox" id="hideRecentBookmarks" />
	</td>
</tr>
<tr>
	<td class="label">
		<label for="hideRecentlyClosedTabs">Hide recently closed tabs: </label>
	</td>
	<td>
		<input type="checkbox" id="hideRecentlyClosedTabs" />
	</td>
</tr>

	<tr><td colspan="2"><hr /></td></tr>
<tr>
	<td colspan="2" class="centerLabel">
	<button onclick="updateXML()">Generate XML</button>
	</td>
<tr>
	<td colspan="2" class="centerLabel">
		Generated XML: 
	</td>
</tr>
<tr>
	<td colspan="2">
		<textarea rows="9" cols="50" id="xmlArea">(Generated xml will be here)</textarea>
	</td>
</tr>
<tr>
	<td colspan="2" class="centerLabel">
		Copy the generated xml and paste it inside <a href="http://dev.chromium.org/user-experience/user-data-directory">user_data_directory</a>/Extensions/[...]AA2/config.xml
	</td>
</table>
	
</div>
<div id="footer"></div>

</div>

</body>
</html>
